<h1>Listing monitor_entries</h1>

Number of users: <%= @survey_users.count %>
</br>
Number of events: <%= @qt_of_events %>
</br>

<table id="sortable-list" class="box-table">
  <thead>
	  <tr>
	    <th data-sort="string" scope="col">User UUID</th>
	    <th data-sort="int" scope="col">Battery Events</th>
		<th data-sort="int" scope="col">Power Connections</th>
		<th data-sort="int" scope="col">via USB</th>
		<th data-sort="int" scope="col">via AC</th>
		<th data-sort="int" scope="col">Power Disconnections</th>
	    <th data-sort="int" scope="col">Connectivity Events</th>
	    <th data-sort="int" scope="col">Net Connections</th>
	    <th data-sort="int" scope="col">via Wi-Fi</th>
	    <th data-sort="int" scope="col">via Mobile</th>
	    <th data-sort="int" scope="col">Net Disconnections</th>
	    <th data-sort="int" scope="col">OS Events</th>
	    <th data-sort="int" scope="col">OS Shutdown</th>
	    <th data-sort="int" scope="col">OS Boot</th>
	    <th data-sort="int" scope="col">Total Events</th>
	    <th data-sort="int" scope="col">Total Days</th>
	    <th data-sort="int" scope="col">Battery Points</th>
	    <th data-sort="int" scope="col">Wi-Fi Points</th>
	    <th data-sort="int" scope="col">3G Points</th>
	  </tr>
  </thead>

	<tbody>
	<% @survey_users.each do |survey_user| %>
	  <% user_total_days = MonitorEntry.get_user_participation_total_days survey_user %>
	  <tr>
	    <td><a href="<%= show_user_entries_path %>?user_uuid=<%= survey_user %>&days_ago=<%= user_total_days+1 %>&threshold=0"><%= survey_user %></a></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class survey_user, MonitorEntry.BATTERY_ENTRY, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.BATTERY_ENTRY, MonitorEntry.POWER_CONNECTED, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_battery_events_quantity_by_type survey_user, MonitorEntry.POWER_TYPE_USB, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_battery_events_quantity_by_type survey_user, MonitorEntry.POWER_TYPE_AC, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.BATTERY_ENTRY, MonitorEntry.POWER_DISCONNECTED, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class survey_user, MonitorEntry.CONNECTIVITY_ENTRY, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.CONNECTIVITY_ENTRY, MonitorEntry.NET_CONNECTED, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_connectivity_events_quantity_by_type survey_user, MonitorEntry.NET_TYPE_WIFI, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_connectivity_events_quantity_by_type survey_user, MonitorEntry.NET_TYPE_MOBILE, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.CONNECTIVITY_ENTRY, MonitorEntry.NET_DISCONNECTED, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class survey_user, MonitorEntry.OS_ENTRY, params[:days_ago] %></td>
	   	<td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.OS_ENTRY, MonitorEntry.OS_SHUTDOWN, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity_by_log_class_and_status survey_user, MonitorEntry.OS_ENTRY, MonitorEntry.OS_BOOT, params[:days_ago] %></td>
	    <td><%= MonitorEntry.get_user_events_quantity survey_user, params[:days_ago] %></td>
	    <td><%= user_total_days %></td>
	    <td><%= MonitorEntry.not_charging_duration_by_time_data(survey_user, params[:threshold], params[:days_ago]).count %></td>
	    <td><%= MonitorEntry.no_connectivity_duration_by_time_data(survey_user, params[:threshold], params[:days_ago], MonitorEntry.NET_TYPE_WIFI).count %></td>
	    <td><%= MonitorEntry.no_connectivity_duration_by_time_data(survey_user, params[:threshold], params[:days_ago], MonitorEntry.NET_TYPE_MOBILE).count %></td>
	  </tr>
	<% end %>
	</tbody>
</table>

<% @time_zones_count.each_pair do |key, value| %>
  <% if value > 0 %>
  	<p>UTC<%= key.to_i/3600000 %> Percentage: <%= number_to_percentage((value.to_d/@survey_users.count.to_d)*100.to_d, precision: 2) %></p>
  <% end %>
<% end %>